<template>
  <div>
    <div class="inputInfo">
      <div class="rel">
        
        <div v-if="users">
          <div class="findRecord"   v-for="(u, index) in users"  :key="index">
              <div class="abc">
                  <div class="recordImage1">{{ index+1 }}</div>
                  <div class="recordImage">{{ u.realName }}</div>
              </div>
          </div>  
        </div>
        <div v-else class="norevenue">
          还没有下级哦( ╯□╰ )
        </div>
      </div>
    </div>

    <div :style="{width:'100%', height:'35px'}"></div>

  </div>
</template>

<script>
import card from '@/components/card'
import { requestPost } from '@/utils/index'
export default {
  components: {
    card
  },
  data () {
    return {
      users: [],
      rows: 20,
      pageSize: 1,
      rtime: 0,
      hasUser: false
    }
  },
  onReachBottom () {
    this.pageSize = this.pageSize + 1
    this.getRecords()
  },
  // onPullDownRefresh () {
  //   wx.stopPullDownRefresh()
  // },
  onShow () {
    this.pageSize = 1
    this.users = []
    this.getRecords()
  },
  onUnload () {
    this.users = []
    this.pageSize = 1
  },
  methods: {
    gopage (pathstr) {
      wx.navigateTo({
        url: pathstr
      })
    },
    getRecords () {
      var data = {
        'userId': mpvue.getStorageSync('userId'),
        'page': this.pageSize,
        'limit': this.rows,
        'token': mpvue.getStorageSync('token')
      }
      var that = this
      requestPost(mpvue.getStorageSync('requestUrl') + '/miniprogram/getChildRecords', data, 'POST').then(function (value) {
        if (value.code === 0) {
          if (value.data.length === 0) {
            wx.showToast({
              title: '暂无下级记录',
              icon: 'none',
              duration: 1500,
              mask: false
            })
            return
          } else {
            that.hasUser = true
          }
          for (var ele of value.data) {
            that.users.push(ele)
          }
        } else {
          wx.showToast({
            title: value.message,
            icon: 'none',
            duration: 1500,
            mask: false
          })
        }
      }, function (value) {
        // wx.hideLoading()
        console.log(value)
      })
    }
  }
}
</script>

<style scoped>
.inputInfo{
  width: 100%;
  height: 150px;
  float:left;
}
.recordImage{
  width: 80%;
  height: 60px;
  float: left;
}
.recordImage1{
  width: 30px;
  height: 30px;
  margin-right:20px;
  margin-left: 10px;
  margin-top:15px;
  line-height: 30px;
  text-align: center;
  float: left;
  background-color: yellow;
  border-radius:50%;
}
.rel{
  width: 100%;
  clear: both;
}

.findRecord{
  width: 100%;
}
.abc{
    margin: 0 auto;
    width: 100%;
    border-bottom:1px rgb(214, 214, 214) solid;
    height: 60px;
    text-align: left;
    line-height: 60px;
    font-size: 20px;
}

.norevenue{
  width: 90%;
  height: 150px;
  line-height: 150px;
  font-size: 30px;
  margin: 0 auto;
  margin-top:20px;
  text-align: center;
  background-color: rgb(238, 238, 238);
  color:rgb(182, 182, 182);
}

</style>
